
    function updateDates(tabId, url) {
    	saveUrl();
    	storageSet('watchedElement', "");
		if(storageGet('elementList') != ""){
			$.each(
				storageGet('elementList').split('|'),
				function(intIndex, element){
					var elementUrl = storageGet(element + '-url');
					if(elementUrl && elementUrl != "" && elementUrl.length > 7 && url.contains(elementUrl)){
						storageSet(element + '-date', new Date().getTime());
						storageSet('watchedElement', element);
						return false;
					}
				}
			);
			notify(tabId);				
		}		
	}

	
	function init(){
		if(!storageGet('elementList')){
			storageSet('elementList', "");
		}
		synchronizeLoop();
		chrome.extension.onRequest.addListener(
			function(request, sender, sendResponse) {
				var response;
				if(request.type == "setWatch"){
					setWatchIcon();
					response = {};
				} else if(request.type == "notify"){
					updateDates(sender.tab.id, request.url);	
				}
				else {
					response = {};
				}
				sendResponse(response);
			});
	}